use "$directory\Standings_RESTAT.dta", clear
sort division season matches standing
gen diff_points_p = points- points[_n+1] if matches== matches[_n+1] & season== season[_n+1]
gen diff_points_m = points- points[_n-1] if matches== matches[_n-1] & season== season[_n-1]
replace diff_points_p = 99 if diff_points_p==.
replace diff_points_m = 99 if diff_points_m==.

save "$directory\standings_diff_RESTAT.dta", replace

